package br.com.guidebar.models;

import android.widget.Adapter;

import java.util.NoSuchElementException;

public class City {
	private Integer id;
	private String name;
	private State state = new State();

	public City(Integer id, String nome) {
		this.id = id;
		this.name = nome;
	}

	public City() {
	}

	@Override
	public String toString() {
		return name;
	}

	public static Integer getPositionById(final Adapter adapter,
			final Integer id) {
		Integer posicao = 0;
		try {
			final int count = adapter.getCount();
			for (int pos = 0; pos < count; pos++) {
				City c = (City) adapter.getItem(pos);

				if (id == (c.getId()).intValue()) {
					posicao = pos;
				}
			}
		} catch (NoSuchElementException erro) {
			erro.printStackTrace();
		}

		return posicao;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

}
